﻿<%@ Page Title="" Language="C#" MasterPageFile="~/masterpage_user.master" AutoEventWireup="true" CodeFile="editQLRaoVat.aspx.cs" Inherits="editQLRaoVat" %>

<asp:Content ID="Content1" ContentPlaceHolderID="user_content" Runat="Server">
    <div class="title">Quản Lý Rao Vặt</div>
    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
        DataKeyNames="Maraovat" DataSourceID="SqlDataSource1" 
        Font-Names="Arial" Height="50px" 
        HorizontalAlign="Center" Width="700px" CssClass="tableView"
        onpageindexchanging="DetailsView1_PageIndexChanging">
        <FieldHeaderStyle 
            HorizontalAlign="Left" VerticalAlign="Middle" />
        <Fields>
            <asp:TemplateField ShowHeader="False">
                <EditItemTemplate>
                    <asp:Button ID="Button1" runat="server" CausesValidation="True" 
                        CommandName="Update" Text="Cập nhật" />
                    &nbsp;<asp:Button ID="Button2" runat="server" CausesValidation="False" 
                        CommandName="Cancel" Text="Hủy" />
                </EditItemTemplate>
                <InsertItemTemplate>
                    &nbsp;
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Button ID="Button1" runat="server" CausesValidation="False" 
                        CommandName="Edit" Text="Sửa" />
                    &nbsp;<asp:Button ID="btQuayLai" runat="server" onclick="btQuayLai_Click" 
                        Text="Quay lại" />
                </ItemTemplate>
                <ItemStyle BackColor="#99CCFF" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Mã Rao Vặt" SortExpression="Maraovat">
                <EditItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Maraovat") %>' 
                        Font-Names="Arial" ForeColor="White"></asp:Label>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Maraovat") %>'></asp:Label>
                </ItemTemplate>
                <ItemStyle Font-Bold="False" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Username" SortExpression="Username">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList1" runat="server" 
                        DataSourceID="SqlDataSource2" DataTextField="Hoten" DataValueField="Username" 
                        SelectedValue='<%# Bind("Username") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("Username") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Tiêu Đề" SortExpression="TieuDe">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("TieuDe") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("TieuDe") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Loại Rao Vặt" SortExpression="loaiRaoVat">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList2" runat="server" 
                        DataSourceID="SqlDataSource3" DataTextField="TENLOAI" 
                        DataValueField="LOAIRAOVAT" SelectedValue='<%# Bind("loaiRaoVat") %>' AppendDataBoundItems="True">
                    <asp:ListItem Text="Chọn lựa..." Value=""></asp:ListItem>
                    </asp:DropDownList>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label4" runat="server" Text='<%# Bind("loaiRaoVat") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Nội Dung" SortExpression="NoiDung">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox6" runat="server" Height="269px" 
                        Text='<%# Bind("NoiDung") %>' TextMode="MultiLine" Width="477px"></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:TextBox ID="TextBox7" runat="server" Font-Names="Arial" Font-Size="Medium" 
                        ForeColor="#507CD1" Height="269px" ReadOnly="True" 
                        Text='<%# Bind("NoiDung") %>' TextMode="MultiLine" Width="477px"></asp:TextBox>
                </ItemTemplate>
            </asp:TemplateField>
        </Fields>
        <HeaderStyle 
            HorizontalAlign="Center" VerticalAlign="Middle" />
    </asp:DetailsView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:chodientuConnectionString %>" 
        DeleteCommand="DELETE FROM [Raovat] WHERE [Maraovat] = @Maraovat" 
        SelectCommand="SELECT * FROM [Raovat] WHERE ([Maraovat] = @Maraovat)" 
        
        
        
        
        
        
        UpdateCommand="UPDATE [Raovat] SET [Username] = @Username, [TieuDe] = @TieuDe, [NoiDung] = @NoiDung, [loaiRaoVat] = @loaiRaoVat WHERE [Maraovat] = @Maraovat">
        <DeleteParameters>
            <asp:Parameter Name="Maraovat" Type="String" />
        </DeleteParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="TextBox1" ConvertEmptyStringToNull="False" 
                Name="Maraovat" PropertyName="Text" Type="String" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="Username" Type="String" />
            <asp:Parameter Name="TieuDe" Type="String" />
            <asp:Parameter Name="NoiDung" Type="String" />
            <asp:Parameter Name="loaiRaoVat" Type="Int32" />
            <asp:Parameter Name="Maraovat" Type="String" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:chodientuConnectionString %>" 
        SelectCommand="SELECT * FROM [Thanhvien] WHERE ([Username] = @Username)">
        <SelectParameters>
            <asp:SessionParameter Name="Username" SessionField="User" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
        ConnectionString="<%$ ConnectionStrings:chodientuConnectionString %>" 
        SelectCommand="SELECT * FROM [BANGGIARAOVAT]"></asp:SqlDataSource>
    <asp:TextBox ID="TextBox1" runat="server" Visible="False"></asp:TextBox>
</asp:Content>

